package com.example.demo.shmanage.controller;

import com.example.demo.loginmanage.service.LoginService;
import com.example.demo.shmanage.service.SHService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Transactional
@CrossOrigin
public class SHController {
    @Autowired
    private SHService shService;
    @Autowired
    private LoginService loginService;

    /**
         * @Description 通过品牌名称查询所有品牌系列
         * @Author zhangxue
         * @Date 11:59 2018/9/5
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryBrandListByBrand",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryBrandListByBrand(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.queryBrandListByBrand(param);
        return statusMap;
    }


    /**
         * @Description 根据条件查询所有商户信息
         * @Author zhangxue
         * @Date 17:34 2018/7/11
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryAllSHInfos",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllSHInfos(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.queryAllSHInfos(param);
        return statusMap;
    }

    /**
         * @Description 新增商户信息
         * @Author zhangxue
         * @Date 11:18 2018/7/12
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/saveSHInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveSHInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveSHInfo(param);
        return statusMap;
    }

    /**
         * @Description 删除商户信息
         * @Author zhangxue
         * @Date 14:30 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/delSHInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> delSHInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.delSHInfo(param);
        return statusMap;
    }

    /**
         * @Description 修改商户信息
         * @Author zhangxue
         * @Date 17:48 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/editSHInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> editSHInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.editSHInfo(param);
        return statusMap;
    }

    /**
         * @Description 查看商户详情
         * @Author zhangxue
         * @Date 16:16 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/initLookInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> initLookInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> resultMap = shService.initLookInfo(param);
        /*Map<String,Object> limMap = loginService.queryLimByUserNo(param);
        if(limMap==null){
            resultMap.put("lim","-1");
        }else{
            String lim = limMap.get("Lim")!=null?limMap.get("Lim").toString():"-1";
            resultMap.put("lim",lim);
        }*/
        return resultMap;
    }

    /**
         * @Description 查询不同类型上传图片
         * @Author zhangxue
         * @Date 9:12 2018/9/12
         * @Param
         * @retrun
         **/
    /**
     * @Description 通过风格和品类查询所有图片
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryImgList",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllImageByStyleAndType(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.queryImgList(param);
        return statusMap;
    }

    /**
         * @Description 添加授权书资料路径
         * @Author zhangxue
         * @Date 11:37 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/uploadBook",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadBook(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadBook(param);
        return statusMap;
    }

    /**
     * @Description 添加执照路径
     * @Author zhangxue
     * @Date 11:37 2018/7/13
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadLicense",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadLicense(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadLicense(param);
        return statusMap;
    }

    /**
         * @Description 添加身份证照片
         * @Author zhangxue
         * @Date 17:06 2018/7/16
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/uploadCard",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadCard(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadCard(param);
        return statusMap;
    }

    /**
     * @Description 添加质检报告照片
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadZjReport",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadZjReport(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadZjReport(param);
        return statusMap;
    }

    /**
     * @Description 添加说明图纸及相关说明照片
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadManageImg",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadManageImg(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadManageImg(param);
        return statusMap;
    }

    /**
     * @Description 添加商标注册照片
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadLogo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadLogo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUploadLogo(param);
        return statusMap;
    }

    /**
     * @Description 添加生产许可证
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadProductPermise",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadProductPermise(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveProductPermise(param);
        return statusMap;
    }

    /**
     * @Description 添加产品使用说明书
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadUseExplain",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadUseExplain(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveUseExplain(param);
        return statusMap;
    }

    /**
     * @Description 添加产品图册
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadProductPhoto",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadProductPhoto(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveProductPhoto(param);
        return statusMap;
    }

    /**
     * @Description 添加相关荣誉证书
     * @Author zhangxue
     * @Date 17:06 2018/7/16
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/uploadHonorBook",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> uploadHonorBook(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveHonorBook(param);
        return statusMap;
    }

    /**
     * @Description 添加其他注意事项
     * @Author zhangxue
     * @Date 15:09 2018/7/13
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/saveOtherInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveOtherInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveOtherInfo(param);
        return statusMap;
    }


    /**
         * @Description 删除不同类型图片
         * @Author zhangxue
         * @Date 10:13 2018/9/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/delSHImage",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> delSHImage(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.delSHImage(param);
        return statusMap;
    }

    /**
         * @Description 查询所有品牌名称
         * @Author zhangxue
         * @Date 17:19 2018/9/7
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/queryBrandList",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryBrandList(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.queryBrandList(param);
        return statusMap;
    }

    /**
     * @Description 根据品牌名称查询所有系列
     * @Author zhangxue
     * @Date 17:19 2018/9/7
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/querySeriesByBrandName",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> querySeriesByBrandName(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.querySeriesByBrandName(param);
        return statusMap;
    }

    /**
     * @Description 初始化展位编辑界面
     * @Author zhangxue
     * @Date 16:16 2018/7/13
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/initZWEditPage",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> initZWEditPage(@RequestBody Map<String,Object> param){
        Map<String,Object> resultMap = shService.initZWEditPage(param);
        return resultMap;
    }

    /**
     * @Description 查询展位品牌下拉
     * @Author zhangxue
     * @Date 8:53 2018/6/3
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryBrandJson")
    @ResponseBody
    public String queryBrandJson(){
        JSONObject js= new JSONObject();
        Map<String,Object> resultMap = new HashMap<String, Object>();
        Map<String,Object> param = new HashMap<String, Object>();
        List<Map<String,Object>> resultList = loginService.queryAllBrand(param);
        resultMap.put("data",resultList);
        js = JSONObject.fromObject(resultMap);
        return js.toString();
    }

    /**
     * @Description 根据条件查询所有展位信息
     * @Author zhangxue
     * @Date 17:34 2018/7/11
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/queryAllZWInfos",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> queryAllZWInfos(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.queryAllZWInfos(param);
        return statusMap;
    }

    /**
         * @Description 新增展位信息
         * @Author zhangxue
         * @Date 15:09 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/saveZWInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveZWInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveZWInfo(param);
        return statusMap;
    }

    /**
         * @Description 删除展位信息
         * @Author zhangxue
         * @Date 17:00 2018/7/13
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/delZWInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> delZWInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.delZWInfo(param);
        return statusMap;
    }

    /**
     * @Description 编辑展位撤场信息
     * @Author zhangxue
     * @Date 17:00 2018/7/13
     * @Param
     * @retrun
     **/
    @RequestMapping(value="/editZWInfo",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> editZWInfo(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.editZWInfo(param);
        return statusMap;
    }

    /**
         * @Description 新增品牌和品牌系列
         * @Author zhangxue
         * @Date 10:42 2018/9/10
         * @Param
         * @retrun
         **/
    @RequestMapping(value="/saveBrandAndSeries",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    @ResponseBody
    public Map<String,Object> saveBrandAndSeries(@RequestBody Map<String,Object> param){
        Map<String,Object> statusMap = shService.saveBrandAndSeries(param);
        return statusMap;
    }
}
